import i18n from "@/lang";
import { orinusRequest } from "@/utils/request";

// import { createService } from "@/utils/request";
// import { AppModule } from '../store/modules/app';
import { encrypt } from '../utils/auth';

// const tunnyApi = (options: any) => createService(AppModule.baseURL)(options);
// const pandaRequest = (options: any) => createService(AppModule.baseURL)(options);

export default class orinusApi {
  /**
   * 获取订单列表
   */
  public getOrders(params: any) {
    return orinusRequest({
      url:  "desktop_orders",
      method: "GET",
      params
    });
  }

  /**
   * 删除订单列表
   */
   public deleteOrder(order_id: any, params: any) {
    return orinusRequest({
      url:  "desktop_orders/" + order_id,
      method: "DELETE",
      params
    });
  }
  /**
   * 订单失败
   */
   public orderFail(orderId: any, params: any) {
    return orinusRequest({
      url:  "desktop_order/" + orderId +"/failed",
      method: "POST",
      params
    });
  }
  /**
   * 获取订单信息
   */
		public getOrderMassage(params: any) {
			return orinusRequest({
				url:  "desktop_order_messages",
				method: "GET",
				params
			});
		}

  /**
   * 订单重做
   */
   public orderRetry(orderId: any, params: any) {
    return orinusRequest({
      url:  "desktop_order/" + orderId + "/redo",
      method: "POST",
      params
    });
  }
	
	/**
	 * 获取订单桌面列表
	 */
	public getOrderDesktops(params: any) {
		return orinusRequest({
			url:  "desktop_order/products",
			method: "GET",
      params
		});
	}

  /**
	 * 创建订单桌面
	 */
	public createOrderDesktop(params: any) {
		return orinusRequest({
			url:  "desktop_order/products",
			method: "POST",
      data: {
        order_id: params.order_id,
        machine_id: params.machine_id,
        desktop_name: params.desktop_name,
        specification_code: params.specification_code,
        mirror_code: params.mirror_code,
        data_disk_size: params.data_disk_size,
        band_width: params.band_width,
        login_url: params.login_url,
        is_deleted: params.is_deleted,
        username: params.username,
        password: params.ad_account_password
      }
		});
	}
  /**
	 * 修改订单桌面
	 */
	public editOrderDesktop(desktopId: any, params: any) {
		return orinusRequest({
			url:  "desktop_order/products/" + desktopId,
			method: "PATCH",
      data: {
        specification_code: params.specification_code,
        mirror_code: params.mirror_code,
        data_disk_size: params.data_disk_size,
        band_width: params.band_width,
        login_url: params.login_url,
        is_deleted: params.is_deleted,
      }
		});
	}
  /**
	 * 删除订单桌面
	 */
   public deleteOrderDesktop(desktopId: any, params: any) {
		return orinusRequest({
			url:  "desktop_order/products/" + desktopId,
			method: "DELETE",
      params
		});
	}

  /**
   * 修改带宽
   */
   public patchBandwidth(desktopId: any, params: any) {
		return orinusRequest({
			url:  "desktop_order/" + desktopId + "/bandwidth/alter",
			method: "PATCH",
      params
		});
	}

  /**
   * 修改订单带宽
   */
   public apiEditOrderBandwidth(order_id: any, params: any) {
    return orinusRequest({
      url: "desktop_order/" + order_id + "/bandwidth",
      method: "POST",
      data: {
        bandwidth: params.band_width
      }
    });
  }

  /**
   * 获取订单设置
   */
   public apiGetOrinusSettings() {
    return orinusRequest({
      url: "/orinus_settings",
      method: "GET",
    });
  }

  /**
   * 更新订单设置
   */
   public apiPatchOrinusSettings(data: any) {
    return orinusRequest({
      url: "/orinus_settings",
      method: "patch",
      data
    });
  }

  // 更改桌面
  public apiPatchDesktop(order_id:any, product_id: any, data: any) {
    return orinusRequest({
      url: '/desktop_order/' + order_id + '/product/' + product_id + '/change',
      method: 'POST',
      data: data
    })
  }

  // 修改订单状态
  public apiPatchOrderStatus(id: any, data: any) {
    return orinusRequest({
      url: '/desktop_orders/' + id,
      method: 'PATCH',
      data
    })
  }
}
